﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBA.Common;
using DBA.Model;
using DBA.Data;
using DBA.Data.ADO;
using DBA.Web.UI;

namespace DBA.Web
{
    public partial class modifypwd : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        DataAccessLibrary dal = CommonQuery.DataAccessLibrary;

        protected void lnkSave_Click(object sender, EventArgs e)
        {
            string strsql = "select Password from EmployeeInfo where EmployeeID='" + ServerContext.AdminCurrentUser.EmployeeID.ToString() + "' ";

            string pwd = dal.ExecuteScalar(strsql).ToString();
            if (txtpwd.Value.Trim() != pwd)
            {
                JsHelper.Alert(this, "旧密码输入错误!");
                return;
            }


            if(txtnew.Value.Trim() != txtconfirm.Value.Trim())
            {
                JsHelper.Alert(this, "两次密码输入不一致!");
                return;
            }

            string strupdate = " update EmployeeInfo set Password='" + txtnew.Value.Trim() + "' where EmployeeID='" + ServerContext.AdminCurrentUser.EmployeeID.ToString() + "' ";

            dal.ExecuteNonQuery(strupdate);

            hdResult.Value = dal.ErrorMessage == "" ? "1" : "0";


            //ServerContext.CurrentUser.EmployeeID
          
        }
    }
}